package com.jiyinit.web.core.common.memory;

import net.sf.ehcache.Element;
import org.springframework.beans.factory.annotation.Autowired;
import net.sf.ehcache.Cache;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.inject.Qualifier;


/**
 * Created by lr on 2017/11/27.
 */
@Component
public class Memory  {

    //@Autowired
    private Cache ehcache; // 注意这里引入的Cache是net.sf.ehcache.Cache

    public void setValue(String key, String value) {
        ehcache.put(new Element(key, value));
    }

    public Object getValue(String key) {
        Element element = ehcache.get(key);
        return element != null ? element.getValue() : null;
    }
}
